

% Finding the moving RMS of the data sets
% written by Tobias Bristow 14/02/13 edited by Edward Brial 18/02/13
% needs filtering before hand!!


windowSize=150;
yrms=[]; % moving RMS, takes RMS of each sample based on window size
yrms(length(newy2)-windowSize)=0;
for i=1:(length(newy2)-windowSize)
    yrms(i)=sqrt(mean(newy(i:i+windowSize).^2));
end
%%
avWinSz=500;
yrmsa=[]; % moving average of the RMS data
yrmsa(length(yrms)-avWinSz)=0;
for a=1:avWinSz
    yrmsa=yrmsa+1/avWinSz*yrms(a:(end-avWinSz+a-1));
end
figure
plot(yrmsa)